package com.wy.test;

import java.util.List;

import com.wy.adapter.MusicAdapter;
import com.wy.domain.Music;
import com.wy.music_player.MusicPlayerActivity;
import com.wy.music_player.R;
import com.wy.utils.MusicList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class SongsListActivity extends Activity{

	private ListView listView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.songs_layout);
		
		// bind UI
		listView = (ListView) findViewById(R.id.listView1);
		// get all music
		List<Music> listMusic= MusicList.getAllMusicData(getApplicationContext());
		MusicAdapter adapter = new MusicAdapter(this, listMusic);
		listView.setAdapter(adapter);

		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int id,
					long arg3) {
				// TODO Auto-generated method stub
				System.out.println("------item click------");
				Intent it = new Intent(SongsListActivity.this,MusicPlayerActivity.class);
				it.putExtra("id", id);
				startActivity(it);
			}
			
		});
	}
	
}
